﻿<?php
    @session_start();
    include("template/head.php");
	$sql = "SELECT * FROM `st_article`,`st_sortie` WHERE `st_article`.id_article = `st_sortie`.id_article";
	$obj = new Mysql ();
	$result = mysql_query($sql);
?>
<style type="text/css">
    #example_filter label input{
        height: 27px;
    }
</style>
    <div class="container-fluid">
        <div class="row-fluid">
                
        <?php include("template/menu_left.php") ?>                

        <div class="span10" id="content">
             <?php
                if ((isset($_GET["action"])) && ($_GET["action"] == "error1"))
                {
                echo'
                <div class="alert alert-danger col-lg-7" style="margin:10px;">
                    Aucune entree au stock n \' a ete effectuer pour <b>'.$_GET["article"].'</b> <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
                if ((isset($_GET["action"])) && ($_GET["action"] == "deleted"))
                {
                echo'
                <div class="alert alert-success col-lg-7" style="margin:10px;">
                    Le sortie de stock est supprimer avec succès <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
				if ((isset($_GET["action"])) && ($_GET["action"] == "added"))
                {
                echo'
                <div class="alert alert-success col-lg-7" style="margin:10px;">
                    Le sortie de stock est enregistrée avec succès <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
                if ((isset($_GET["action"])) && ($_GET["action"] == "updated"))
                {
                echo'
                <div class="alert alert-success col-lg-7" style="margin:10px;">
                    Mise à jour de sortie de stock est effectuée avec succès. <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
				if ((isset($_GET["action"])) && ($_GET["action"] == "addedError"))
                {
                echo'
                <div class="alert alert-danger col-lg-7" style="margin:10px;">
                    Le sortie de stock n\'est pas enregistrer. ressayer plus tard. <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
                if ((isset($_GET["action"])) && ($_GET["action"] == "error3"))
                {
                echo'
                <div class="alert alert-danger col-lg-7" style="margin:10px;">
                    Sortie superieur a la quantité du produit  pour <b>'.$_GET["article"].'</b> <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }

                if ((isset($_GET["action"])) && ($_GET["action"] == "error1"))
                {
                echo'
                <div class="alert alert-danger col-lg-7" style="margin:10px;">
                    Aucune entree au stock n \' a ete effectuer pour <b>'.$_GET["article"].'</b> <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }
                if ((isset($_GET["action"])) && ($_GET["action"] == "error2"))
                {
                echo'
                <div class="alert alert-danger col-lg-7" style="margin:10px;">
                    Limite stock  :'.$_GET["article"].'</b> <button type="button" class="close" data-dismiss="alert">&times;</button>
                </div>
                ';
                }

            ?>    
            <div class="row-fluid">
            <!-- block -->
            <div class="block">
              <div class="navbar navbar-inner block-header">
                <div class="muted pull-left">Liste sortie des Articles (<?php  $num = mysql_num_rows($result); echo $num ; ?>)</div>
              	<div class="pull-right"><a class="btn btn-primary btn-sm" href="add_sortie.php?page=list_sortie" style="float:right;width:200px;margin-bottom:20px;" >Ajouter une opération de vente</a></div>
              </div>
              <div class="block-content collapse in">
                <div class="span12">
                    <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
                    <thead>
                      <tr>
				        <th>Réf. Article</th>
						<th>Désignation</th>
						<th>Qté en Stock</th>
						<th>Prix Vente</th>
                        <th></th>
                      </tr>
                    </thead>
                    <tbody>
                       <?php while($row = mysql_fetch_object($result)) { ?>        
                      	<tr class="odd gradeX">
                        <td>
			            <?php 
			                $rq = "select * from st_article where ref_article = '".getRefArticle($row->id_article)."'";
			                $res = mysql_query($rq);
			                while($rowPhoto = mysql_fetch_object($res)){
			                    echo '
			                    <a class="fancybox-effects-a" href="'.$rowPhoto->photo_name.'">'.getRefArticle($row->id_article).'</a>';
			                }
			            ?>	
			            </td>
					 	<td><?php echo nl2br(getDesignation($row->id_article))?></td>
					 	<td class="center" style="color:#d0343a;text-align:center;"><?php echo number_format($row->Quantite, 0, '', ' ') ?></td>
					 	<td class="center" style="text-align:center;"><?php echo number_format(getPrixVenteArticle($row->id_article), 3, '.', ' ') ?></td>
                        <td>
                            <a href="view_list_sortie_for_product.php?page=list_sortie&id_article=<?php echo $row->id_article?>" class="btn btn-small" style="margin-right:20px;">Consultation</a>      
                        </td>
                      </tr>
                      <?php
                        }
                      ?>
                    </tbody>
                  </table>
                </div>
                <a class="btn btn-primary btn-sm" href="add_sortie.php?page=list_sortie" style="float:right;width:200px;margin:20px;" >Ajouter une opération de vente</a>
              </div>
            </div>
        <!-- /block -->
          </div>
                </div>
            </div>
            <hr>
        </div>
<?php  include("template/footer.php") ; ?>